package com.prs.crm.dao.taskmanager.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.context.AppContext;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.taskmanager.PersonalTaskResultDao;
import com.prs.crm.domain.taskmanager.PersonalTaskResult;

public class PersonalTaskResultDaoImpl extends BaseDaoImpl<PersonalTaskResult>	implements PersonalTaskResultDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<PersonalTaskResult> getAllPersonalTaskResult() {
		Criteria criteria=this.getSession().createCriteria(PersonalTaskResult.class);
		return criteria.list();
	}

	@Override
	public PersonalTaskResult getPersonalTaskResults(String type) {
		Criteria criteria=this.getSession().createCriteria(PersonalTaskResult.class);
		criteria.add(Restrictions.eq("type", AppContext.getAccountContext().getUser().getResume().getName()));
		List result=criteria.list();
		if(result==null || result.size()==0){
			return null;
		}
		return (PersonalTaskResult) criteria.list().get(0);
	}
}
